﻿@using Lib.core;
@using Lib.helper;

@using Bll;
@using Model;
@{
    Layout = null;
}

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!-- header page -->
    @Html.Partial(IncludePath("header"))
    <style type="text/css">
        select {
            width: 200px;
        }
    </style>
</head>

<body>
    @Html.Partial(IncludePath("body_top"))
    @Html.Partial(IncludePath("manage_nav"))

    <div class="container-fluid setting" style="margin-top: 10px;">

        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">网站名称：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control"
                                       name="web_name" value="@(ViewData["web_name"])" data-value="@(ViewData["web_name"])" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">关键词：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control"
                                       name="web_keywords" value="@(ViewData["web_keywords"])" data-value="@(ViewData["web_keywords"])" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">网站描述：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control"
                                       name="web_description" value="@(ViewData["web_description"])" data-value="@(ViewData["web_description"])" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <div class="box">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">联系电话：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control"
                                       name="web_phone" value="@(ViewData["web_phone"])" data-value="@(ViewData["web_phone"])" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">电子邮箱：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control"
                                       name="web_email" value="@(ViewData["web_email"])" data-value="@(ViewData["web_email"])" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">位置：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control"
                                       name="web_address" value="@(ViewData["web_address"])" data-value="@(ViewData["web_address"])" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <div class="box">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否可以注册：</label>
                            <div class="col-sm-9">
                                <select class="form-control" name="can_reg" data-value="@(ViewData["can_reg"])">
                                    <option value="true">可以</option>
                                    <option value="false">不可以</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <div class="box">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">网站皮肤：</label>
                            <div class="col-sm-9">
                                <select class="form-control" name="bootTheme" data-value="@(ViewData["bootTheme"])">
                                    <option value="">默认主题</option>
                                    <option value="cerulean">天蓝色</option>
                                    <option value="flat">扁平</option>
                                    <option value="journal">杂志</option>
                                    <option value="paper">Material Design</option>
                                    <option value="simplex">简约</option>
                                    <option value="slate">石质</option>
                                    <option value="spacelab">太空实验室</option>
                                    <option value="standstone">砂岩</option>
                                    <option value="united">统一</option>
                                    <option value="yeti">白雪</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <div class="box">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">Head Bottom：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control"
                                       name="head_bottom"
                                       value="@(ViewData["head_bottom"])"
                                       data-value="@(ViewData["head_bottom"])" />
                            </div>
                        </div>
                    </div>
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">Body Top：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control"
                                       name="body_top"
                                       value="@(ViewData["body_top"])"
                                       data-value="@(ViewData["body_top"])" />
                            </div>
                        </div>
                    </div>
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">Body Bottom：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control"
                                       name="body_bottom"
                                       value="@(ViewData["body_bottom"])"
                                       data-value="@(ViewData["body_bottom"])" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
            var form = $('.setting');
            var inputs = form.find('input');
            inputs.each(function (i) {
                var input = inputs.eq(i);
                input.on('blur', function () {
                    //没有修改
                    if (input.val() == input.attr('data-value')) { return; }
                    postJson('/admin/setting/SaveSettingAction/',
                        {
                            key: input.attr('name'),
                            value: input.val()
                        },
                        function (res) {
                            if (res && res.success) {
                                alert('保存成功');
                                window.location.reload();
                            }
                            else {
                                alert(res.msg);
                            }
                        });
                });
            });

            var selects = form.find('select');
            selects.each(function (i) {
                var select = selects.eq(i);
                select.on('change', function () {
                    if (select.val() == select.attr('data-value')) { return; }
                    postJson('/admin/setting/SaveSettingAction/',
                        {
                            key: select.attr('name'),
                            value: select.val()
                        },
                        function (res) {
                            if (res && res.success) {
                                alert('保存成功');
                                window.location.reload();
                            }
                            else {
                                alert(res.msg);
                            }
                        });
                });
            });
        });
    </script>
    @Html.Partial(IncludePath("body_bottom"))
</body>
</html>
